<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
        <style>
            .container{
                display: flex;
                flex-direction: column;
            }
            img{
                width: 200px;
                height: 200px;
            }

        </style>
</head>
<body>
    <div class="container">
        <img src="./loading.gif" data-src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fq_70%2Cc_zoom%2Cw_640%2Fimages%2F20180725%2F70875e0c1b224d7c92007d79eba4bb74.jpeg&refer=http%3A%2F%2F5b0988e595225.cdn.sohucs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1661339229&t=77ef48fc7983fd6118d93fc8252161cf">
        
        <img src="./loading.gif" data-src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fq_70%2Cc_zoom%2Cw_640%2Fimages%2F20180725%2F70875e0c1b224d7c92007d79eba4bb74.jpeg&refer=http%3A%2F%2F5b0988e595225.cdn.sohucs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1661339229&t=77ef48fc7983fd6118d93fc8252161cf">

        <img src="./loading.gif" data-src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fq_70%2Cc_zoom%2Cw_640%2Fimages%2F20180725%2F70875e0c1b224d7c92007d79eba4bb74.jpeg&refer=http%3A%2F%2F5b0988e595225.cdn.sohucs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1661339229&t=77ef48fc7983fd6118d93fc8252161cf">

        <img src="./loading.gif" data-src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fq_70%2Cc_zoom%2Cw_640%2Fimages%2F20180725%2F70875e0c1b224d7c92007d79eba4bb74.jpeg&refer=http%3A%2F%2F5b0988e595225.cdn.sohucs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1661339229&t=77ef48fc7983fd6118d93fc8252161cf">

        <img src="./loading.gif" data-src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fq_70%2Cc_zoom%2Cw_640%2Fimages%2F20180725%2F70875e0c1b224d7c92007d79eba4bb74.jpeg&refer=http%3A%2F%2F5b0988e595225.cdn.sohucs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1661339229&t=77ef48fc7983fd6118d93fc8252161cf">

        <img src="./loading.gif" data-src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fq_70%2Cc_zoom%2Cw_640%2Fimages%2F20180725%2F70875e0c1b224d7c92007d79eba4bb74.jpeg&refer=http%3A%2F%2F5b0988e595225.cdn.sohucs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1661339229&t=77ef48fc7983fd6118d93fc8252161cf">

        <img src="./loading.gif" data-src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fq_70%2Cc_zoom%2Cw_640%2Fimages%2F20180725%2F70875e0c1b224d7c92007d79eba4bb74.jpeg&refer=http%3A%2F%2F5b0988e595225.cdn.sohucs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1661339229&t=77ef48fc7983fd6118d93fc8252161cf">

        <img src="./loading.gif" data-src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fq_70%2Cc_zoom%2Cw_640%2Fimages%2F20180725%2F70875e0c1b224d7c92007d79eba4bb74.jpeg&refer=http%3A%2F%2F5b0988e595225.cdn.sohucs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1661339229&t=77ef48fc7983fd6118d93fc8252161cf">

        <img src="./loading.gif" data-src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fq_70%2Cc_zoom%2Cw_640%2Fimages%2F20180725%2F70875e0c1b224d7c92007d79eba4bb74.jpeg&refer=http%3A%2F%2F5b0988e595225.cdn.sohucs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1661339229&t=77ef48fc7983fd6118d93fc8252161cf">

        <img src="./loading.gif" data-src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fq_70%2Cc_zoom%2Cw_640%2Fimages%2F20180725%2F70875e0c1b224d7c92007d79eba4bb74.jpeg&refer=http%3A%2F%2F5b0988e595225.cdn.sohucs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1661339229&t=77ef48fc7983fd6118d93fc8252161cf">

        <img src="./loading.gif" data-src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fq_70%2Cc_zoom%2Cw_640%2Fimages%2F20180725%2F70875e0c1b224d7c92007d79eba4bb74.jpeg&refer=http%3A%2F%2F5b0988e595225.cdn.sohucs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1661339229&t=77ef48fc7983fd6118d93fc8252161cf">

        <img src="./loading.gif" data-src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fq_70%2Cc_zoom%2Cw_640%2Fimages%2F20180725%2F70875e0c1b224d7c92007d79eba4bb74.jpeg&refer=http%3A%2F%2F5b0988e595225.cdn.sohucs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1661339229&t=77ef48fc7983fd6118d93fc8252161cf">
        
        <img src="./loading.gif" data-src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fq_70%2Cc_zoom%2Cw_640%2Fimages%2F20180725%2F70875e0c1b224d7c92007d79eba4bb74.jpeg&refer=http%3A%2F%2F5b0988e595225.cdn.sohucs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1661339229&t=77ef48fc7983fd6118d93fc8252161cf">
        
        <img src="./loading.gif" data-src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2F5b0988e595225.cdn.sohucs.com%2Fq_70%2Cc_zoom%2Cw_640%2Fimages%2F20180725%2F70875e0c1b224d7c92007d79eba4bb74.jpeg&refer=http%3A%2F%2F5b0988e595225.cdn.sohucs.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1661339229&t=77ef48fc7983fd6118d93fc8252161cf">
        
    </div>
    <script>
        let img = document.querySelectorAll('img');
        function loading(){
            img.forEach(item=>{
                if(item.offsetTop < window.innerHeight + window.scrollY){
                    item.src = item.getAttribute('data-src')
                }
            })
        }
        loading();
        window.onscroll = function(){
            loading();
        }

    </script>
</body>
</html>